<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function parse_content($content_left=NULL, $content_middle=NULL, $content_right=NULL){
    $CI = &get_instance();
    $CI->load->module_define('home');
   
    $CI->load->module_model('home.page_model');
    $CI->load->module_model('home.parse_model');
    
    $title_tag_text = $desc_tag_text = $keyword_tag_text = '';		
    if($content_left!=NULL && $content_middle!=NULL && $content_right!=NULL){		
        $content_left = $CI->parse_model->parse_content($content_left);
        $content_middle = $CI->parse_model->parse_content($content_middle);
        $content_right = $CI->parse_model->parse_content($content_right);       
                
        $page_active = 1;
    }else{
		$page_name =  $CI->uri->segment(1);
		
        $content_middle = $content_left = $content_right= "";        
        if(!$CI->page_model->get_by_pname($page_name))
            $page_name = 'Trang-Chu';
        $CI->page_model->get_by_pname($page_name);

        $content_middle = $content_left = $content_right= "";		
        if($CI->page_model->content_middle)
            $content_middle = $CI->parse_model->parse_content($CI->page_model->content_middle);
        if($CI->page_model->content_left)
            $content_left = $CI->parse_model->parse_content($CI->page_model->content_left);
        if($CI->page_model->content_right)
            $content_right = $CI->parse_model->parse_content($CI->page_model->content_right);

        
        $page_active = $CI->page_model->active;
    }
	
    //Get image path
    $CI->load->library("fckeditor", array('fid'=>$CI->page_model->admin_id));
    $path = $CI->fckeditor->UploadPath.'/images';
    
    $path = base_url().str_replace($CI->config->slash_item('base_url'), '', $path);

    return array('admin_id' => $CI->page_model->admin_id,
                 'block_show_flag' => $CI->page_model->show_flag,
                 'content_left' => $content_left,
                 'content_middle' => $content_middle,
                 'content_right' => $content_right,
                 'page_active' => $page_active,
                 'title_tag' => $title_tag_text,
                 'description_tags' => $desc_tag_text,
                 'keywords_tags' => $keyword_tag_text,
                 );
}